import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  Image,
  ScrollView,
  TouchableOpacity,
  DeviceEventEmitter,
  Platform,
  Dimensions,
  NativeAppEventEmitter,
  InteractionManager,
} from 'react-native';

import styles from './orderDetailStyle';
import ProgressBar from '../global/ProgressBar';
import helper from '../util/helper';
import api from '../../services/api';
import Toast from 'react-native-sk-toast';
import Communications from 'react-native-communications';
import AMap from '../global/amapView/AMap';
import moment from 'moment';
import _ from 'lodash';

import Touch from '../global/Touch';
import ImagePicker from 'react-native-image-picker';
import * as config from '../../constants/apiConfig';
import LoadingTip from '../global/LoadingTip';
import ToastTip from '../global/ToastTip';
import { Navigation } from '../global/navigation/index';
import SimpleDialog from '../global/SimpleDialog';
import EasemobChat from '../global/EasemobChat';
import CancelOrderReasonDialog from './cancelOrderReasonDialog';

const {width: deviceWidth, height: deviceHeight} = Dimensions.get('window');

class OrderDetail extends Component {
    constructor(props) {
		super(props);
        this.state = {
            showLoading: false,
            showMap: true,
            tracks: null,
            userName: '',
            receiveActionDisabled: false,
            completeActionDisabled: false,
            orderDetail: null,
            open:false,
            showCancelDialog:false,
            openDeletePicture:false,
            images:[],
            nursingPictureList:[],
            openHandSignDialog:false,
		};

        this.serviceTypeMap = {
            'send': {'m':this._renderSend.bind(this),'index':0},
            'buy': {'m':this._renderBuy.bind(this),'index':1},
            'express': {'m':this._renderExpress.bind(this),'index':2},
            'lockkey': {'m':this._renderLockkey.bind(this),'index':3},
            'other': {'m':this._renderOhter.bind(this),'index':4},
            'nursing':{'m':this._renderNursing.bind(this),'index':5}
        }

        this.props.navigator.setOnNavigatorEvent(this._onNavigatorEvent.bind(this));
        this.Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
        this._amap = null;

	}

    chooseType = (type) => {
        switch (type) {
            case "other":
                return  "其他"
            case "report":
                return  "报事"
            case "repair":
                return "报修"
            case "shops":
                return "特权"
            case "activity":
                return "活动报名"
            default:
               return  "预约办理"
        }
    }

    componentWillMount() {
		// this._retrieveDetails();
        // this._onRefresh();
    }

    async _onRefresh(){
        // let {actions, dispatch} = this.props;
        this.setState({showLoading:true, showMap: true,isShowLoadBar:false});
        // let action = actions.order.order_getorder(this.props.orderId);
        let detail = await api.post('/order/detail',{id: this.props.orderId});
        console.log('test======_onRefresh',detail);
        if (detail.data && detail.data.service_type == "express") {
            let pictureFileListResult = await api.post('/order/getImageByOrderId',{orderId:this.props.orderId});
            console.log('test======_onRefresh=pictureFileList',pictureFileListResult);
            if (pictureFileListResult.cd == 0 && pictureFileListResult.data && pictureFileListResult.data.remarkImage) {
                this.setState({
                    pictureFileList:pictureFileListResult.data.remarkImage,
                })
            }
        }
        if (detail.data && detail.data.inServiceImages && detail.data.inServiceImages.length != 0) {

            let nursingPictureList = detail.data.inServiceImages;
            // nursingPictureList.push({id:-1,url:""})
            this.setState({
                nursingPictureList,
            })
        }
        let serviceFee = await api.post('/order/getServiceFeeByOrderId',{oid:this.props.orderId})
        console.log('test======/order/getServiceFeeByOrderId',serviceFee);

        let tracksdetail = await api.post("/order/tracksdetail",{id:this.props.orderId});

        this._mounted && this.setState({showLoading:false, tracks: tracksdetail.data});
        let res = detail;

        if(res && res.cd == 1){
            this.setState({isShowLoadBar:true});
            this.refs.toast.show(res.msg);
            return;
        }

        // if (serviceFee && serviceFee.cd == 0 && serviceFee.data) {
        //     this.setState({
        //         serviceFee:serviceFee.data
        //     })
        // }

        let info = res && res.data;
        let userInfo = await api.post("/account/findUserById",{uid: info.kehu_id});
        console.log('/account/findUserById============',userInfo);
        this.setState({
            userName: (userInfo && userInfo.data.name) || decodeURIComponent(userInfo.data.wxName),
            orderDetail: info,
            ownerInfo:userInfo.data
        });

        if (serviceFee.data && serviceFee.data.length > 0 && userInfo.data && userInfo.data.isVip == 1 && userInfo.data.keeperServiceLeftCount > 0) {
            let totalServiceFee = 0.00;
            for (var i = 0; i < serviceFee.data.length; i++) {
                if (serviceFee.data[i].feeAmount) {
                    totalServiceFee = parseFloat(parseFloat(totalServiceFee)+parseFloat(serviceFee.data[i].feeAmount)).toFixed(2);
                }
            }

            console.log('serviceFee--------------=',serviceFee.data);
            this.setState({
                showVipTips:true,
                serviceFee:serviceFee.data,
                totalServiceFee
            })
        }else{
            console.log('serviceFee--------------=',serviceFee.data);
            this.setState({
                showVipTips:false,
                serviceFee:serviceFee.data
            })
        }

        this.loaded = true;
        // this._searchRidingRoute(info);
        if(Platform.OS == 'ios'){
            InteractionManager.runAfterInteractions(() => {
                this._searchRidingRoute(info);
            });
        }else{
            InteractionManager.runAfterInteractions(() => {
                this.timeIdex = setTimeout(() =>{
                    this._searchRidingRoute(info);
                }, 200);
            });
        }



        // dispatch(action).then(async()=>{
        //
        //
        // });

    }

    _onNavigatorEvent(event) {


		if (event.type === 'NavBarButtonPress') {
			if (event.id === 'reload') {
                this._onRefresh();
			}
		}

        if (event.id === 'didAppear') { //出现时
            this.clearTime = setTimeout(()=>{this._onRefresh();},500)
            // this._onRefresh();
		}

        if (event.id === 'willDisappear') { //消失时
            this.setState({showMap: false});
		}
	}

    componentDidMount(){
        let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
        this._subcribOrder = Emitter.addListener('hand.sign.success', this._handWritingSignSuccess.bind(this));
        this._mounted = true;
        this.clearTime && clearTimeout(this.clearTime);
        // this._searchRidingRoute();
        // this._onRefresh();
    }

    componentWillUnmount() {
        this._mounted = false;
        this.timeIdex && clearTimeout(this.timeIdex);
        this._subcribSign && this._subcribSign.remove();
        // let {actions, dispatch} = this.props;
        // dispatch(actions.order.order_clear_cardobj());
        // this.detailSubcribe && this.detailSubcribe.remove();
    }

    componentWillReceiveProps(nextProps) {
    //   if (nextProps.order.order_detail) {
    //
    //   }
    }

    componentDidUpdate(){


    }

    _handWritingSignSuccess(){

        this._onRefresh()
    }

    _sendPhone(phone){
        Communications.phonecall(phone, true);
    }

    async _receiveOrder(info){
        // 接单
        let res = await api.post("/order/updatestatus",{id:info.id,status:2,cancelReason:''});
        if(res.data){
            // let ownerInfo = await api.post('/housekeeper/ownerinfobyphone',{phone: info.user_phone});
            // if(ownerInfo.data){
                // let send_text = "";
                // let { session } = this.props;
                //
                // if(info.service_type == 'send' || info.service_type == 'lockkey'){
                //     send_text = "您的管家"+(session && session.user.keeper_name)+"正在赶来的路上。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
                // }else if (info.service_type == "buy") {
                //     send_text = "您的管家"+(session && session.user.keeper_name)+"已在路上（联系电话"+(session && session.user.phone)+"）。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
                // }else if (info.service_type == "express") {
                //     send_text = "您的管家"+(session && session.user.keeper_name)+"已在取快递的路上（联系电话"+(session && session.user.phone)+"）。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
                // }else if (info.service_type == "other") {
                //     send_text = "您的管家"+(session && session.user.keeper_name)+"已经前往为您服务（联系电话"+(session && session.user.phone)+"）。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
                // }
                //
                // let json = JSON.stringify({
                //                 "touser":ownerInfo.data.wxOpenId,
                //                 "msgtype":"text",
                //                 "text":
                //                 {
                //                      "content":send_text,
                //                 }
                //                 // "customservice":
                //                 // {
                //                 //     "kf_account": session && session.user.kf_account
                //                 // }
                //             });
                //
                // let send_res = await api.post('/wx/customsend',{json});
            // }else {

            // }

            Toast.bottom("接单成功");
            this.Emitter.emit('order.onload');
            this.props.navigator.pop();
        }
    }

    async _getObj(info, phone){
        var options = {
            title: '拍照获取物品照片',
            cancelButtonTitle: "取消",
            takePhotoButtonTitle:'拍照',
            chooseFromLibraryButtonTitle:'选择相册',
            permissionDenied: {
              title: '提示',
              text: '没有拍照和获取相册权限',
              reTryTitle: '重试',
              okTitle: '确定',
            },
            quality: 0.8,
            maxHeight: parseInt(deviceHeight*2),
            maxWidth: parseInt(deviceWidth*2),
            storageOptions: {
                skipBackup: true,
                path: 'images'
            }
        };
        // 照片
        ImagePicker.showImagePicker(options, (response)  => {
            // Same code as in above section!
            if (response.error) {
            }else{
                if (response.didCancel) {
                   return;
                }

                InteractionManager.runAfterInteractions(() => {
                    this.props.navigator.push({
                        title: '确认物品照片',
            			screen: 'housekeeperapp.imagepicker',
                        backButtonTitle:'',
            			passProps: {
                            from:'detail',
                            orderId: info.id,
                            orderPhone: phone,
                            orderType: info.service_type,
                            fileUri:response.uri,
                            otherServiceType:info.otherServiceType,
            				// source: 'data:image/jpeg;base64,' + response.data
            			},
                        navigatorStyle:{
                            tabBarHidden: true,
                            navBarTextColor: 'white',
                        	navBarButtonColor: 'white',
                        	navBarBackgroundColor: '#EA5404',
                            statusBarColor: '#EA5404',
                            navBarTitleTextCentered: true,
                            topBarElevationShadowEnabled:false
                        },
                        navigatorButtons: {
                            leftButtons:[
                                {
                                    id: 'back',
                                    icon: require("../../../img/hk_back_icon.png")
                                }
                            ]
            			}
            		});
                });

            }

        });
        return false;

        //我已取货
        // let res = await api.post("/order/updatestatus",{id,status:3});
        // if(res.data){
        //     Toast.bottom("我已取货");
        //     this.Emitter.emit('order.onload');
        //     this.props.navigator.pop();
        // }
    }

    async _getComplete(info){

        if(info.service_type=='buy'){//如果是代买，需要填写商品金额后才能完成订单
            this.props.navigator.push({
                title: '商品金额',
                screen: 'housekeeperapp.inputgoodsprice',
                backButtonTitle:'',
                passProps: {
                    order_info: {
                        id: info.id,
                        user_phone: info.user_phone
                    }
                },
                navigatorStyle:{
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                    navBarButtonColor: 'white',
                    statusBarColor: '#EA5404',
                    navBarBackgroundColor: '#EA5404',
                    navBarTitleTextCentered: true,
                    topBarElevationShadowEnabled:false
                },
                navigatorButtons: {
                    leftButtons:[
                        {
                            id: 'back',
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
            });
            return;
        }

        if(info.service_type=='other' || info.service_type == "nursing"){//如果是其他订单，需要进入完成订单页才能完成订单
            this.props.navigator.push({
                title: '完成服务',
                screen: 'housekeeperapp.servicecompletion',
                backButtonTitle:'',
                passProps: {
                    order_info: {
                        id: info.id,
                        user_phone: info.user_phone,
                        othertype: info.otherServiceType,
                        orderType: info.service_type,
                        needUploadImage:info.finishImages && info.finishImages.length != 0 ?false:true,
                        finishImages:info.finishImages,
                        status:info.status,
                    }
                },
                navigatorStyle:{
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                    navBarButtonColor: 'white',
                    statusBarColor: '#EA5404',
                    navBarBackgroundColor: '#EA5404',
                    navBarTitleTextCentered: true
                },
                navigatorButtons: {
                    leftButtons:[
                        {
                            id: 'back',
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
            });
            return;
        }

        if (info.service_type == "express") {
            this.props.navigator.push({
                title: '完成服务',
                screen: 'housekeeperapp.servicecompletion',
                backButtonTitle:'',
                passProps: {
                    order_info: {
                        id: info.id,
                        user_phone: info.user_phone,
                        orderType: info.service_type,
                        status:info.status,
                    },
                    info:info
                },
                navigatorStyle:{
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                    navBarButtonColor: 'white',
                    statusBarColor: '#EA5404',
                    navBarBackgroundColor: '#EA5404',
                    navBarTitleTextCentered: true
                },
                navigatorButtons: {
                    leftButtons:[
                        {
                            id: 'back',
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
            });
            return;
        }

        // 代送取照片
        if(info.service_type=='send'){
            this._getObj(info, info.user_phone);
            return;
        }

        //我已送达
        let res = await api.post("/order/updatestatus",{id:info.id,status:4,cancelReason:''});
        if(res.data){
            // let ownerInfo = await api.post('/housekeeper/ownerinfobyphone',{phone: info.user_phone});
            // if(ownerInfo.data){
            //     let send_text = "";
            //     let orderTrack = await api.post('/order/tracksdetail',{id: info.id});

            //     if(orderTrack.data){
            //         let delayTime = ((moment(orderTrack.data.order_endsend_time) - moment(orderTrack.data.order_hkget_time))/60000).toFixed(0);

            //         let { session } = this.props;
            //         let web_base_url = "";
            //         if (session && session.user && session.user.product && session.user.product.baseUrl) {
            //             web_base_url = session.user.product.baseUrl;
            //         }else{
            //             web_base_url = config.WEB_BASE_URL;
            //         }

            //         if (info.service_type=='other' && info.otherServiceType == 'activity') {
            //             send_text = "您的订单已完成。<a href='" + web_base_url + "/weichart/order?order_id="+info.id+"&type=ORDER_REWARD'>评价服务</a>";
            //         } else if (info.service_type == 'nursing') {
            //             send_text = "您的订单已完成，耗时"+delayTime+"分钟。<a href='" + web_base_url + "/weichart/order?order_id="+info.id+"&type=ORDER_REWARD'>评价服务</a>";
            //         }else{
            //             send_text = "您的订单已完成，耗时"+delayTime+"分钟。<a href='" + web_base_url + "/weichart/order?order_id="+info.id+"&type=ORDER_REWARD'>评价服务</a>";
            //         }
                    

            //         let json = JSON.stringify({
            //                         "touser":ownerInfo.data.wxOpenId,
            //                         "msgtype":"text",
            //                         "text":
            //                         {
            //                              "content":send_text,
            //                         }
            //                         // "customservice":
            //                         // {
            //                         //     "kf_account": session && session.user.kf_account
            //                         // }
            //                     });

            //         let send_res = await api.post('/wx/customsend',{json});
            //     }

            // }

            Toast.bottom("我已完成");
            this.Emitter.emit('order.onload');
            InteractionManager.runAfterInteractions(() => {
                this.props.navigator.pop();
            });
        }else{
            Toast.bottom("该笔订单已完成，请刷新后重试");
            this.Emitter.emit('order.onload');
        }
    }

    


    

    async _editOrder(info){
        if(!this.loaded){
            return false;
        }

        let res = await api.post("/order/detail",{id:info.id});
        this.enterEdit = true;

        InteractionManager.runAfterInteractions(() => {
            this.props.navigator.push({
                title: '编辑任务',
    			screen: 'housekeeperapp.addorder',
                backButtonTitle:'',
    			passProps: {
    				source: 'edit',
                    data: res.data,
                    page: this.serviceTypeMap[info.service_type]['index']
    			},
                navigatorStyle:{
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                	navBarButtonColor: 'white',
                    statusBarColor: '#EA5404',
                	navBarBackgroundColor: '#EA5404',
                    navBarTitleTextCentered: true,
                    topBarElevationShadowEnabled:false
                },
                navigatorButtons: {
                    leftButtons:[
                        {
                            id: 'back',
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
    		});
        });

    }

    _onDidMoveByUser(){
        // console.log("######", '11');
        // let info = this.props.order.order_detail && this.props.order.order_detail.data;
        // // this._searchRidingRoute(info);
        // InteractionManager.runAfterInteractions(() => {
        //     this._searchRidingRoute(info);
        // });
    }

    _searchRidingRoute(order){
        if(!this._mounted){
            return;
        }

        if(!order){
            return;
        }

        if(order.start_location && order.start_location){
            let start_latitude = parseFloat(order.start_location.split(',')[0]),
                start_longitude = parseFloat(order.start_location.split(',')[1]);

            let dest_latitude = parseFloat(order.dest_location.split(',')[0]),
                dest_longitude = parseFloat(order.dest_location.split(',')[1]);

            this._amap && this._amap.searchRidingRoute({
                start_latitude,
                start_longitude,
                dest_latitude,
                dest_longitude
            });
        }

    }

    _editAppeal(info){
        let title = "";
        if(info.appeal_status == 0){
            title = "我要申诉";
        }else if(info.appeal_status == 1) {
            title = "申诉中";
        }else if(info.appeal_status == 2 || info.appeal_status == 3) {
            title = "申诉结果";
        }

        this.props.navigator.push({
            title: title,
            screen: 'housekeeperapp.orderappeal',
            backButtonTitle:'',
            passProps: {
                orderId: info.id,
                appealStatus: info.appeal_status
            },
            navigatorStyle:{
                tabBarHidden: true,
                navBarTextColor: 'white',
                navBarButtonColor: 'white',
                navBarBackgroundColor: '#EA5404',
                statusBarColor: '#EA5404',
                navBarTitleTextCentered: true,
                topBarElevationShadowEnabled:false
            },
            navigatorButtons: {
                leftButtons:[
                    {
                        id: 'back',
                        icon: require("../../../img/hk_back_icon.png")
                    }
                ]
            }
        });
    }

    _renderStar(score){
        var compArr = [];
        for (var i = 0; i < score; i++) {
            compArr.push(<Image key={i} source={require('../../../img/hk_small_active_star_icon.png')} style={styles.smallstarImage}/>);
        }

        for (var i = 0; i < 5-score; i++) {
            compArr.push(<Image key={5+i} source={require('../../../img/hk_small_star_icon.png')} style={styles.smallstarImage}/>);
        }

        return (<View style={[styles.tagsContainer,{alignItems: 'center'}]}>
            {compArr}
        </View>);
    }

    _renderTags(tags){
        var tagArr = tags.indexOf(',') != -1? tags.split(',') : [tags];
        var compArr = [];
        for (var i = 0; i < tagArr.length; i++) {
            compArr.push(<Text key={i} style={styles.tagsItem}>{tagArr[i]}</Text>);
        }

        return (<View style={styles.tagsContainer}>
            {compArr}
        </View>);
    }

    _clickExpressOrderImage(index){
        let {pictureFileList} = this.state;
        if (pictureFileList && pictureFileList[index]) {//有图片则预览
            this._previewExpressOrderPicture(pictureFileList,index)
            return;
        }
    }

    _previewExpressOrderPicture(fileUris,index){
        let fileUriString = "";
        for (var i = 0; i < fileUris.length - 1; i++) {
            fileUriString += fileUris[i].url+",";
        }
        fileUriString += fileUris[fileUris.length - 1].url;
        Navigation.startPreviewPictureActivity({"currentIndex":index,"fileUris":fileUriString,"isUrl":true});
    }

    _clickImage(type){
        let { orderDetail } = this.state;
        if (type == 'remarkImage') {
            if (orderDetail && orderDetail.remarkImage) {//有图片则预览
                console.log('test==========_clickImage',orderDetail.remarkImage);
                this._previewPicture(orderDetail.remarkImage)
                return;
            }
        }else if (type == 'obj_image') {
            if (orderDetail && orderDetail.obj_image) {//有图片则预览
                console.log('test==========_clickImage',orderDetail.obj_image);
                this._previewPicture(orderDetail.obj_image)
                return;
            }
        }else if (type == 'finishImages') {
            if (orderDetail && orderDetail.finishImages) {//有图片则预览
                console.log('test==========_clickImage',orderDetail.finishImages[0].url);
                this._previewPicture(orderDetail.finishImages[0].url,true)
                return;
            }
        }else if (type == 'obj_finish_image') {
            if (orderDetail && orderDetail.obj_finish_image) {//有图片则预览
                console.log('test==========_clickImage',orderDetail.obj_finish_image);
                this._previewPicture(orderDetail.obj_finish_image)
                return;
            }
        }else if (type == 'autographImage') {
            if (orderDetail && orderDetail.autographImage) {//有图片则预览
                console.log('test==========_clickImage',orderDetail.autographImage.url);
                this._previewPicture(orderDetail.autographImage.url,true)
                return;
            }
        }
        
    }

    _previewPicture(fileUri,isUrl){
        if (isUrl) {
            isUrl = true;
        }else{
            isUrl = false;
        }
        Navigation.startPreviewPictureActivity({"currentIndex":0,"fileUris":fileUri,"isUrl":isUrl})
    }

    _previewNursingPicture(index){
        let {nursingPictureList} = this.state;
        let fileUri = "";
        nursingPictureList.map((item,index) => {
            if (index != nursingPictureList.length - 1) {
                fileUri += item.url+",";
            }
        })
        fileUri += nursingPictureList[nursingPictureList.length - 1].url
        console.log('test',fileUri);
        
        Navigation.startPreviewPictureActivity({"currentIndex":index,"fileUris":fileUri,"isUrl":true})
    }

    _renderEvaluate(info){
        if (info.reward_score) {
            let status_text = "", textStyle;
            if(info.appeal_status == 0){
                status_text = "我要申诉";
                textStyle = {color:'#5DBAFD'};
            }else if(info.appeal_status == 1){
                status_text = "申诉中";
                textStyle = {color:'#5DBAFD'};
            }else if(info.appeal_status == 2){
                status_text = "申诉成功";
                textStyle = {color:'#5CCC50'};
            }else if(info.appeal_status == 3){
                status_text = "申诉失败";
                textStyle = {color:'#F5615F'};
            }

            let {tracks, userName} = this.state;
            let s = "";
            if (info.service_type == "nursing") {
                s = "用户"
            }else{
                s = "业主"
            }

            return (
                <View style={[styles.fPart,{marginTop:10,paddingRight:0}]}>
                    <View style={styles.objInfoTitle}>
                        <Text style={{textAlign:'left',color:'#7B7B7B',marginBottom: 11.5, fontSize: 15}}>{s}评价</Text>
                        {info.reward_evaluate?<Touch style={styles.appealBtnTouch} activeOpacity={0.7} onPress={this._editAppeal.bind(this, info)}>
                            <Text style={[styles.appealBtn, textStyle]}>{status_text}</Text>
                        </Touch>:null}
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>{s}姓名</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{userName}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>打赏金额</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.reward_price.toFixed(2)+'元'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>评价分数</Text>
                        {this._renderStar(info.reward_score)}
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>评价日期</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{(tracks && tracks.order_reward_time)?tracks.order_reward_time:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>评价标签</Text>
                        {this._renderTags(info.reward_flags)}
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>评价详情</Text>
                        <Text style={[styles.objSubTitle,{flex:4,marginRight: 15}]}>{info.appeal_status==2?"该评价由于含有敏感词汇，已被系统过滤":(info.reward_evaluate?info.reward_evaluate:'无')}</Text>
                    </View>
                </View>
            );
        } else {
            return null;
        }

    }

    _renderService(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        if(user_role == 1){
            if(info.isThirdParty){
                return (
                    <View style={[styles.fPart,{marginTop:10}]}>
                        <View style={styles.objInfo}>
                            <Text style={styles.objTitle}>服务方</Text>
                            <Text style={[styles.objSubTitle,{flex:4}]}>{info.thirdPartyName}</Text>
                        </View>
                        <View style={styles.objInfo}>
                            <Text style={styles.objTitle}>服务姓名</Text>
                            <Text style={[styles.objSubTitle,{flex:4}]}>{info.thirdPartyPerson?info.thirdPartyPerson:'无'}</Text>
                        </View>
                        <View style={styles.objInfo}>
                            <Text style={styles.objTitle}>服务手机号</Text>
                            <Text style={[styles.objSubTitle,{flex:4}]}>{info.thirdPartyPhone}</Text>
                        </View>
                    </View>
                )
            }else{
                if(info.status > 1){
                    return (
                        <View style={[styles.fPart,{marginTop:10}]}>
                            <View style={styles.objInfo}>
                                <Text style={styles.objTitle}>服务方</Text>
                                <Text style={[styles.objSubTitle,{flex:4}]}>管家</Text>
                            </View>
                            <View style={styles.objInfo}>
                                <Text style={styles.objTitle}>服务姓名</Text>
                                <Text style={[styles.objSubTitle,{flex:4}]}>{info.keeperName}</Text>
                            </View>
                            <View style={styles.objInfo}>
                                <Text style={styles.objTitle}>服务手机号</Text>
                                <Text style={[styles.objSubTitle,{flex:4}]}>{info.keeperPhone}</Text>
                            </View>
                        </View>
                    )
                }else{
                    return null;
                }
            }
        }else{
            return null;
        }
    }

    // _renderVipServiceFee(info){
    //     let {serviceFee} = this.state;
    //     let user_role = this.props.session.user && this.props.session.user.role;

    //     if (info.serviceFee_pay_status == 0) {
    //         return null;
    //     }
    //     if (info.serviceFee_pay_status == -1) {
    //         return(
    //         <View style={styles.objInfo}>
    //                 <Text style={styles.objTitle}>取消原因</Text>
    //                 <Text style={[styles.objSubTitle,{flex:4}]}>{info.cancelReason}</Text>
    //             </View>)
    //     }
    //     if (info.serviceFee_pay_status == -2) {
    //         return(
    //                 <View style={styles.objInfo}>
    //                     <Text style={styles.objTitle}>取消原因</Text>
    //                     <Text style={[styles.objSubTitle,{flex:4}]}>超时取消</Text>
    //                 </View>
    //         )
    //     }

    //     if (serviceFee && serviceFee.length == 0) {
    //         return null;
    //     }
    //     return(
    //         <View>
    //         {serviceFee.map((item,index) => {
    //             return(
    //                 <View style={styles.objInfo} key={index}>
    //                     <Text style={styles.objTitle}>{item && item.serviceFeeName?item.serviceFeeName:'服务费'}</Text>
    //                     <Text style={[styles.objSubTitle,{flex:4}]}>¥{user_role == 1 ? item.feeAmount:item.keeperDivideAmount}</Text>
    //                 </View>)
    //         })}
    //         <View style={styles.objInfo}>
    //             <Text style={styles.objTitle}>支付状态</Text>
    //             <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceFee_pay_status == 1 ? '未支付' : '已支付' }</Text>
    //         </View>
    //         </View>
    //     )
    // }

    _renderServiceFee(info){
        let {serviceFee = [],showVipTips} = this.state;
        console.log('_renderServiceFee-------',serviceFee);
        let user_role = this.props.session.user && this.props.session.user.role;
        // if (showVipTips) {
        //     if (info.isVipOrder == 1) {
        //         if (info.serviceFeeVipReduction == 1) {
        //             return(
        //                 <View>
        //                     {serviceFee.map((item,index) => {
        //                         return(
        //                             <View style={styles.objInfo} key={index}>
        //                                 <Text style={styles.objTitle}>{item && item.feeName?item.feeName:'服务费'}</Text>
        //                                 <Text style={[styles.objSubTitle,{flex:4}]}>¥{user_role == 1 ? item.feeAmount:item.keeperDivideAmount}</Text>
        //                             </View>)
        //                     })}
        //                     <View style={styles.objInfo}>
        //                         <Text style={styles.objTitle}>支付状态</Text>
        //                         <Text style={[styles.objSubTitle,{flex:4}]}>VIP免费</Text>
        //                     </View>
        //                 </View>
        //             )
        //         }
        //     }else{

        //     }
            

        // }else{

            if (info.serviceFee_pay_status == 0) {
                if (info.isVipOrder == 1) {
                    if (info.serviceFeeVipReduction == 1) {
                        return(
                            <View>
                            {serviceFee.map((item,index) => {
                                return(
                                    <View style={styles.objInfo} key={index}>
                                        <Text style={styles.objTitle}>{item && item.feeName?item.feeName:'服务费'}</Text>
                                        <Text style={[styles.objSubTitle,{flex:4}]}>¥{user_role == 1 ? parseFloat(item.feeAmount).toFixed(2):parseFloat(item.keeperDivideAmount).toFixed(2)}</Text>
                                    </View>)
                            })}
                            {serviceFee.length > 0?
                                <View style={styles.objInfo}>
                                    <Text style={styles.objTitle}>支付状态</Text>
                                    <Text style={[styles.objSubTitle,{flex:4}]}>VIP免费</Text>
                                </View>
                                :
                                null
                            }
                            
                            </View>
                        )
                    }
                    // else{
                    //     return(
                    //         <View>
                    //         {serviceFee.map((item,index) => {
                    //             return(
                    //                 <View style={styles.objInfo} key={index}>
                    //                     <Text style={styles.objTitle}>{item && item.feeName?item.feeName:'服务费'}</Text>
                    //                     <Text style={[styles.objSubTitle,{flex:4}]}>¥{user_role == 1 ? item.feeAmount:item.keeperDivideAmount}</Text>
                    //                 </View>)
                    //         })}
                    //         {serviceFee.length > 0?
                    //             <View style={styles.objInfo}>
                    //                 <Text style={styles.objTitle}>支付状态</Text>
                    //                 <Text style={[styles.objSubTitle,{flex:4}]}>VIP免费</Text>
                    //             </View>
                    //             :
                    //             null
                    //         }
                            
                    //         </View>
                    //     )
                    // }
                }else{
                    return null;
                }
            }
            if (info.serviceFee_pay_status == -1) {
                return(
                <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>取消原因</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.cancelReason}</Text>
                    </View>)
            }
            if (info.serviceFee_pay_status == -2) {
                return(
                        <View style={styles.objInfo}>
                            <Text style={styles.objTitle}>取消原因</Text>
                            <Text style={[styles.objSubTitle,{flex:4}]}>超时取消</Text>
                        </View>
                )
            }

            if (serviceFee && serviceFee.length == 0) {
                return null;
            }
            return(
                <View>
                    {serviceFee.map((item,index) => {
                        return(
                            <View style={styles.objInfo} key={index}>
                                <Text style={styles.objTitle}>{item && item.feeName?item.feeName:'服务费'}</Text>
                                <Text style={[styles.objSubTitle,{flex:4}]}>¥{user_role == 1 ? parseFloat(item.feeAmount).toFixed(2):parseFloat(item.keeperDivideAmount).toFixed(2)}</Text>
                            </View>)
                    })}
                    {serviceFee.length > 0?
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>支付状态</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceFee_pay_status == 1 ? '未支付' : '已支付' }</Text>
                    </View>
                    :
                    null}
                </View>
            )
        // }
        
        

        // {
        //     info.serviceFee_pay_status != 0?
        //     <View>
        //         <View style={styles.objInfo}>
        //             <Text style={styles.objTitle}>{serviceFee && serviceFee.serviceFeeName?serviceFee.serviceFeeName:'夜间服务费'}</Text>
        //             <Text style={[styles.objSubTitle,{flex:4}]}>{user_role == 1 ? info.serviceFee:info.order_price}</Text>
        //         </View>
        //         <View style={styles.objInfo}>
        //             <Text style={styles.objTitle}>支付状态</Text>
        //             <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceFee_pay_status == 1 ? '未支付' : info.serviceFee_pay_status == 2 ? '已支付' : info.isPay ? '已退款' : '已取消' }</Text>
        //         </View>
        //     </View>
        //     :
        //     null
        // }

        // {
        //     info.serviceFee_pay_status  == -1 ?
        //         <View style={styles.objInfo}>
        //             <Text style={styles.objTitle}>取消原因</Text>
        //             <Text style={[styles.objSubTitle,{flex:4}]}>{info.cancelReason}</Text>
        //         </View>
        //         :
        //         info.serviceFee_pay_status == -2 ?
        //             <View style={styles.objInfo}>
        //                 <Text style={styles.objTitle}>取消原因</Text>
        //                 <Text style={[styles.objSubTitle,{flex:4}]}>超时取消</Text>
        //             </View>
        //         :
        //         null
        // }
    }

    _renderSend(info){
        let {serviceFee} = this.state;
        let user_role = this.props.session.user && this.props.session.user.role;
        let start_latitude = info.start_location && info.start_location.split(',')[0],
            start_longitude = info.start_location && info.start_location.split(',')[1];

        return (
             <View style={styles.sendContainer}>
                 <View style={styles.fPart}>
                    <View style={[styles.moneyInfo,{paddingBottom:0,borderBottomWidth:0}]}>
                        {info.status != 0 ? <View style={styles.leftrightInfo}>
                                {/*<View style={styles.moneyLeftInfo}>
                                    <Text style={styles.numStyle}>{info.order_price.toFixed(2)}</Text>
                                    <Text style={styles.subStyle}>本单收入(元)</Text>
                                </View>*/}
                                {info.status!=4?
                                <View style={[styles.moneyRightInfo,{borderLeftWidth:0}]}>
                                    <Text style={styles.numStyle}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/60000).toFixed(0)}<Text style={styles.unitStyle}>分钟</Text></Text>
                                    <Text style={styles.subStyle}>服务剩余时间</Text>
                                </View>:null}
                            </View>:<Text style={styles.noMoneyText}>用户未支付服务费</Text>
                        }
                    </View>
                </View>

                <View style={{position: 'relative', height: 175}}>
                    {start_latitude && start_longitude && this.state.showMap?<AMap
                    ref={ component => this._amap = component }
                    style={{flex: 1, }}
                    options={{
                        frame: {
                            width: deviceWidth,
                            height: 175
                        },
                        showsUserLocation: false,
                        userTrackingMode: Platform.OS == 'ios' ? AMap.constants.userTrackingMode.none : null,
                        centerCoordinate: {
                            latitude: parseFloat(start_latitude),
                            longitude: parseFloat(start_longitude)
                        },
                        zoomLevel: 14.1,
                        centerMarker: Platform.OS == 'ios' ? 'icon_location' : 'poi_marker_1',
                    }}
                    onDidMoveByUser={this._onDidMoveByUser.bind(this)}
                    />:null}
                </View>
                <View style={[styles.fPart,{borderTopWidth:0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>寄</Text>
                        <Text style={styles.objSubTitle}>{info.from_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收</Text>
                        <Text style={styles.objSubTitle}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>
                    
                    {this._renderServiceFee(info)}
                    
                    

                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>
                    {
                        info.remarkImage?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'remarkImage')}>
                                <Image source={{uri: info.remarkImage}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                            null
                    }
                </View>

                <View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>订单编号</Text>
                        <Text style={[styles.objSubTitle]}>{info.number}</Text>
                        
                        <View style={styles.vipImageContainer}>
                            {info.isVipOrder == 1 ? <Image source={require('../../../img/vip.png')} style={styles.vipImage}/>:null}
                        </View>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>下单时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.create_time}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>发件电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收件电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>物品名称</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.obj_name}</Text>
                    </View>
                    {/*{info.status != 0?
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>本单收入</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.order_price.toFixed(2)+'元'}</Text>
                    </View>:null}*/}
                </View>

                {this._renderService(info)}

                {this._renderEvaluate(info)}

                {info.obj_image?<View style={[styles.fPart,info.obj_finish_image?{marginTop:10}:{marginTop:10,marginBottom: 55}]}>
                    <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>图片详情1</Text>
                    <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'obj_image')}>
                        <Image source={{uri:info.obj_image}} style={{height: 280}} resizeMode={'stretch'}/>
                    </TouchableOpacity>
                </View>:null}

                {info.obj_finish_image?<View style={[styles.fPart,{marginTop:10,marginBottom: 55}]}>
                    <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>图片详情2</Text>
                    <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'obj_finish_image')}>
                        <Image source={{uri:info.obj_finish_image}} style={{height:280, flex:1}} resizeMode={'stretch'}/>
                    </TouchableOpacity>
                </View>:null}

            </View>
        );
    }

    _renderBuy(info){
        let {serviceFee} = this.state;
        let user_role = this.props.session.user && this.props.session.user.role;
        let start_latitude = info.start_location && info.start_location.split(',')[0],
            start_longitude = info.start_location && info.start_location.split(',')[1];

        return (
            <View style={styles.sendContainer}>
                 
                {info.status != 0 ? 
                        <View style={styles.fPart}>
                            <View style={[styles.moneyInfo,!info.start_location?{paddingBottom:0,borderBottomWidth:0}:{}]}>
                                <View style={styles.leftrightInfo}>
                                    {/*<View style={styles.moneyLeftInfo}>
                                        <Text style={styles.numStyle}>{info.order_price.toFixed(2)}</Text>
                                        <Text style={styles.subStyle}>本单收入(元)</Text>
                                    </View>*/}
                                    {info.status!=4?
                                    <View style={[styles.moneyRightInfo,{borderLeftWidth:0}]}>
                                        <Text style={styles.numStyle}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/60000).toFixed(0)}<Text style={styles.unitStyle}>分钟</Text></Text>
                                        <Text style={styles.subStyle}>服务剩余时间</Text>
                                    </View>:null}
                                </View>
                            </View>
                        </View>
                    :
                        <View style={styles.fPart}>
                            <View style={[styles.moneyInfo,!info.start_location?{paddingBottom:0,borderBottomWidth:0}:{}]}>
                                <Text style={styles.noMoneyText}>用户未支付服务费</Text>
                            </View>
                        </View>
                }
                {info.start_location && this.state.showMap?
                    <View style={{position: 'relative', height: 175}}>
                        <AMap
                        ref={ component => this._amap = component }
                        style={{flex: 1, }}
                        options={{
                            frame: {
                                width: deviceWidth,
                                height: 175
                            },
                            showsUserLocation: false,
                            userTrackingMode: Platform.OS == 'ios' ? AMap.constants.userTrackingMode.none : null,
                            centerCoordinate: {
                                latitude: parseFloat(start_latitude),
                                longitude: parseFloat(start_longitude)
                            },
                            zoomLevel: 14.1,
                            centerMarker: Platform.OS == 'ios' ? 'icon_location' : 'poi_marker_1',
                        }}
                        onDidMoveByUser={this._onDidMoveByUser.bind(this)}
                        />
                </View>:null}
                   <View style={[styles.fPart,{borderTopWidth:0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>购买物品</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.obj_name}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>购买地址</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.from_address?info.from_address:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收货地址</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>


                    
                    
                    {this._renderServiceFee(info)}

                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>

                    {
                        info.remarkImage?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'remarkImage')}>
                                <Image source={{uri: info.remarkImage}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                            null
                    }
                </View>

                <View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>订单编号</Text>
                        <Text style={[styles.objSubTitle]}>{info.number}</Text>
                        
                        <View style={styles.vipImageContainer}>
                            {info.isVipOrder == 1 ? <Image source={require('../../../img/vip.png')} style={styles.vipImage}/>:null}
                        </View>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>下单时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.create_time}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收货电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                    {info.obj_price?<View style={styles.objInfo}>
                        <Text style={styles.objTitle}>期望价格</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.obj_price.toFixed(2)+'元'}</Text>
                    </View>:null}
                    {info.obj_pay_status == 1 || info.obj_pay_status == 2?
                        <View style={styles.objInfo}>
                            <Text style={styles.objTitle}>物品金额</Text>
                            <Text style={[styles.objSubTitle,{flex:4}]}>{info.obj_actual_price.toFixed(2)+'元'}</Text>
                        </View>:null}

                    {/*{info.status != 0?
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>本单收入</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.order_price.toFixed(2)+'元'}</Text>
                    </View>:null}*/}
                </View>

                {this._renderService(info)}

                {this._renderEvaluate(info)}

                {
                    info.obj_image?
                        
                            <View style={[styles.fPart,{marginTop:10,marginBottom: 55}]}>
                                <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>图片详情</Text>
                                <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'obj_image')}>
                                    <Image source={{uri:info.obj_image}} style={{height: 280}}/>
                                </TouchableOpacity>
                            </View>
                        
                    :
                    null
                }

            </View>
        );
    }

    _renderExpress(info){
        let {serviceFee,pictureFileList} = this.state;
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
             <View style={styles.sendContainer}>
                <View style={styles.fPart}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.express_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>

                    
                    {this._renderServiceFee(info)}
                    
                </View>

                <View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>订单编号</Text>
                        <Text style={[styles.objSubTitle]}>{info.number}</Text>
                        <View style={styles.vipImageContainer}>
                            {info.isVipOrder == 1 ? <Image source={require('../../../img/vip.png')} style={styles.vipImage}/>:null}
                        </View>
                        
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>下单时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.create_time}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收件电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收件地址</Text>
                        <Text style={[styles.objSubTitle ,{flex:4}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>

                    <View style={{marginTop: 10 }}>
                        {pictureFileList[0]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,0)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}

                                >

                                        <Image source={{uri:pictureFileList[0].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>  

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[1]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,1)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[1].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[2]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,2)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[2].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[3]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,3)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[3].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[4]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,4)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[4].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[5]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,5)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[5].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[6]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,6)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[6].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[7]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,7)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[7].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[8]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,8)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[8].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                        {pictureFileList[9]?

                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickExpressOrderImage.bind(this,9)}
                                    disabled={this.state.disableUpload}
                                    style={{marginBottom: 10}}
                                >

                                        <Image source={{uri:pictureFileList[9].url}} resizeMode="contain" style={{width:deviceWidth,height:deviceWidth}}/>

                                </TouchableOpacity>

                            :
                            null
                        }
                    </View>   
                    
                    {
                        info.remarkImage?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'remarkImage')}>
                                <Image source={{uri: info.remarkImage}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                            null
                    }
                </View>

                {
                    info.expressCostStatus==1?<View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务明细</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.expressDetails?info.expressDetails:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务金额</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.expressCost}元</Text>
                    </View>
                    </View>:null
                }
                {
                    info.expressCostStatus==2?<View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务明细</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.expressDetails?info.expressDetails:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务金额</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.expressCost}元</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>支付时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{this.state.tracks?this.state.tracks.order_endsend_time:null}</Text>
                    </View>
                    </View>:null
                }

                {this._renderService(info)}

                {this._renderEvaluate(info)}

                {info.obj_image?<View style={[styles.fPart,{marginTop:10,marginBottom: 55}]}>
                    <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>图片详情</Text>
                    <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'obj_image')}>
                        <Image source={{uri:info.obj_image}} resizeMode="contain" style={{height: 280}}/>
                    </TouchableOpacity>
                </View>:null}

            </View>
        );
    }

    _renderLockkey(info){
        return (
             <View style={styles.sendContainer}>
                <View style={styles.fPart}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.lockkey_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.service_time}</Text>
                    </View>
                </View>

                <View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>订单编号</Text>
                        <Text style={[styles.objSubTitle]}>{info.number}</Text>
                        <View style={styles.vipImageContainer}>
                            {info.isVipOrder == 1 ? <Image source={require('../../../img/vip.png')} style={styles.vipImage}/>:null}
                        </View>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>下单时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.create_time}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>业主电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务地址</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>
                    {
                        info.remarkImage?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'remarkImage')}>
                                <Image source={{uri: info.remarkImage}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                            null
                    }
                </View>

                {this._renderService(info)}

                {this._renderEvaluate(info)}
                {info.obj_image?<View style={[styles.fPart,{marginTop:10,marginBottom: 55}]}>
                    <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>图片详情</Text>
                    <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'obj_image')}>
                        <Image source={{uri:info.obj_image}} resizeMode="contain" style={{height: 280}}/>
                    </TouchableOpacity>
                </View>:null}

            </View>
        );
    }

    

    _openCancel(info){

        this.setState({
            showCancelDialog: true,
            service_type:info.otherServiceType,
        });
    }

    async _robOrder(info){//抢单
        let res = await api.post("/order/rob",{id:info.id});
        if(res.cd == 1 || !res.data){
            EasemobChat.showOrderFailDialog();
            setTimeout(() =>{
                this.props.navigator.pop();
                this.Emitter.emit('order.onload');
            }, 5010);

        }else{
            // InteractionManager.runAfterInteractions(() => {
            //
            // });
            this.props.navigator.pop();

            Toast.bottom("抢单成功");
            this.Emitter.emit('gotoPage', 1);
            this.Emitter.emit('order.onload');
        }
    }

    _dispatchOrder(info, isdispatch){
        Navigation.startDispatchActivity({'order_id': info.id, isdispatch});
    }

    _turnOrder(info){
        this.setState({
            open: true,
            turn: 1
        });
    }

    _renderRemarks(info){


        if (!info.remarks) {//内容为空
            return null;
        }

        let r = info.remarks.split('#');
        if (r.length == 0 || r.length == 1) {
            return (
                        <View style={[styles.fPart,{marginTop:10}]}>
                            <Text style={styles.objTitle}>{info.remarks}</Text>
                        </View>
                    )
        }else{
            let rr = "";
            for (var i = 0; i < r.length - 1; i++) {
                rr += r[i]+"\n";
            }

            if (info.otherServiceType == 'activity' && info.remarks) {
                return (
                        <View style={[styles.fPart,{marginTop:10}]}>
                        
                            <Text style={styles.objTitle}>{rr}</Text>
                        </View>
                    )
            }else{
                return null;
            }
        }
        
    }

    _renderOhter(info){
        // info.remarks = "订单内容：圈儿*1\n支付金额：0\n圈儿1信息\n服务日期2019-01-25\n服务时间09:00\n";
        
        
        // var reg = new RegExp( '&' , "g" );
        // var newstr = info.remarks.replace( reg , '\n' );
        // info.remarks = newstr;

        // console.log('test------------================',info);

        let {serviceFee} = this.state;
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
            <View style={styles.sendContainer}>
                 <View style={styles.fPart}>
                    
                    {info.status != 0 ? 
                        <View style={styles.moneyInfo}>
                            <View style={styles.leftrightInfo}>
                                {/*<View style={styles.moneyLeftInfo}>
                                    <Text style={styles.numStyle}>{info.order_price.toFixed(2)}</Text>
                                    <Text style={styles.subStyle}>本单收入(元)</Text>
                                </View>*/}
                                {info.status!=4?
                                <View style={[styles.moneyRightInfo,{borderLeftWidth:0}]}>
                                    <Text style={styles.numStyle}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/60000).toFixed(0)}<Text style={styles.unitStyle}>分钟</Text></Text>
                                    <Text style={styles.subStyle}>服务剩余时间</Text>
                                </View>:null}
                            </View>
                        </View>
                        :
                        <View style={styles.moneyInfo}>
                            <Text style={styles.noMoneyText}>用户未支付服务费</Text>
                        </View>
                    }
                    <View style={[styles.objInfo,{marginTop:10}]}>
                        <Text style={styles.objTitle}>服务类型</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{this.chooseType(info.otherServiceType)}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.other_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>
                    
                    {this._renderServiceFee(info)}
                </View>

                <View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>订单编号</Text>
                        <Text style={[styles.objSubTitle]}>{info.number}</Text>

                        <View style={styles.vipImageContainer}>
                            {info.isVipOrder == 1 ? <Image source={require('../../../img/vip.png')} style={styles.vipImage}/>:null}
                        </View>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>下单时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.create_time}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>业主电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务地址</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.to_address}</Text>
                    </View>
                    {/*{info.status != 0?
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>本单收入</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.order_price.toFixed(2)+'元'}</Text>
                    </View>:null}*/}
                </View>
                {
                    info.servicePayStatus==1?<View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务明细</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceCostDetail?info.serviceCostDetail:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务金额</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceCost}元</Text>
                    </View>
                    </View>:null
                }
                {
                    info.servicePayStatus==2?<View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务明细</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceCostDetail?info.serviceCostDetail:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务金额</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceCost}元</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>支付时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{this.state.tracks?this.state.tracks.order_endsend_time:null}</Text>
                    </View>
                    </View>:null
                }
                {this._renderEvaluate(info)}

                {this._renderRemarks(info)}

                {
                        info.remarkImage?
                            <View style={[styles.fPart,{marginTop:10}]}>
                                <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'remarkImage')}>
                                    <Image source={{uri: info.remarkImage}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                                </TouchableOpacity>
                            </View>
                        :
                            null
                    }

                {info.obj_image?<View style={[styles.fPart,{marginTop:10,marginBottom: 55}]}>
                    <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>图片详情</Text>
                    <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'obj_image')}>
                        <Image source={{uri:info.obj_image}} resizeMode="contain" style={{height: 280}}/>
                    </TouchableOpacity>
                </View>:null}

            </View>
        );
    }


    _renderNursing(info){
        let {serviceFee} = this.state;
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
            <View style={styles.sendContainer}>
                 <View style={styles.fPart}>
                    <View style={styles.moneyInfo}>
                        {info.status != 0 ? <View style={styles.leftrightInfo}>
                                {/*<View style={styles.moneyLeftInfo}>
                                    <Text style={styles.numStyle}>{info.order_price.toFixed(2)}</Text>
                                    <Text style={styles.subStyle}>本单收入(元)</Text>
                                </View>*/}
                                {info.status!=4?
                                <View style={[styles.moneyRightInfo,{borderLeftWidth:0}]}>
                                    <Text style={styles.numStyle}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/60000).toFixed(0)}<Text style={styles.unitStyle}>分钟</Text></Text>
                                    <Text style={styles.subStyle}>服务剩余时间</Text>
                                </View>:null}
                            </View>:<Text style={styles.noMoneyText}>用户未支付服务费</Text>
                        }
                    </View>
                    <View style={[styles.objInfo,{marginTop:10}]}>
                        <Text style={styles.objTitle}>服务类型</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>护理服务</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.other_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>
                    
                    {this._renderServiceFee(info)}
                </View>

                <View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>订单编号</Text>
                        <Text style={[styles.objSubTitle]}>{info.number}</Text>

                        <View style={styles.vipImageContainer}>
                            {info.isVipOrder == 1 ? <Image source={require('../../../img/vip.png')} style={styles.vipImage}/>:null}
                        </View>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>下单时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.create_time}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>用户电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务地址</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.to_address}</Text>
                    </View>
                    {/*{info.status != 0?
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>本单收入</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.order_price.toFixed(2)+'元'}</Text>
                    </View>:null}*/}
                </View>
                {
                    info.unservedCostPayStatus == 0?
                        null
                    :
                        info.unservedCostPayStatus == 1 ?
                            <View style={[styles.fPart,{marginTop:10}]}>
                                <View style={styles.objInfo}>
                                    <Text style={styles.objTitle}>护理服务费用明细</Text>
                                    <Text style={[styles.objSubTitle,{flex:4}]}>{info.unservedCostDetail?info.unservedCostDetail:'无'}</Text>
                                </View>
                                <View style={styles.objInfo}>
                                    <Text style={styles.objTitle}>护理服务费用</Text>
                                    <Text style={[styles.objSubTitle,{flex:4}]}>{info.unservedCost}元</Text>
                                </View>
                            </View>
                        :
                            <View style={[styles.fPart,{marginTop:10}]}>
                                <View style={styles.objInfo}>
                                    <Text style={styles.objTitle}>护理服务费用明细</Text>
                                    <Text style={[styles.objSubTitle,{flex:4}]}>{info.unservedCostDetail?info.unservedCostDetail:'无'}</Text>
                                </View>
                                <View style={styles.objInfo}>
                                    <Text style={styles.objTitle}>护理服务费用</Text>
                                    <Text style={[styles.objSubTitle,{flex:4}]}>{info.unservedCost}元</Text>
                                </View>
                                <View style={styles.objInfo}>
                                    <Text style={styles.objTitle}>支付时间</Text>
                                    <Text style={[styles.objSubTitle,{flex:4}]}>{this.state.tracks && this.state.tracks.order_unserved_pay_time?this.state.tracks.order_unserved_pay_time:null}</Text>
                                </View>
                            </View>
                }

                {
                    info.servicePayStatus==1 || info.servicePayStatus==2?<View style={[styles.fPart,{marginTop:10}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务明细</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceCostDetail?info.serviceCostDetail:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务金额</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.serviceCost}元</Text>
                    </View>
                    </View>:null
                }
                
                {this._renderEvaluate(info)}

                {this._renderRemarks(info)}

                
                {this._renderPicture(info)}
                

                {
                    info.remarkImage?
                        <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'remarkImage')}>
                            <View style={[styles.fPart,{marginTop:10}]}>
                                <Image source={{uri: info.remarkImage}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </View>
                        </TouchableOpacity>
                    :
                        null
                }

                {
                    info.obj_image?
                        <View style={[styles.fPart,{marginTop:10}]}>
                            <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>开始服务</Text>
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'obj_image')}>
                                <Image source={{uri:info.obj_image}} resizeMode="contain" style={{height: 280}}/>
                            </TouchableOpacity>
                        </View>
                    :
                        null
                }

                {
                    info.finishImages && info.finishImages.length != 0?
                        <View style={[styles.fPart,{marginTop:10}]}>
                            <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>服务完成</Text>
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'finishImages')}>
                                <Image source={{uri:info.finishImages[0].url}} resizeMode="contain" style={{height: 280}}/>
                            </TouchableOpacity>
                        </View>
                    :
                        null
                }

                {
                    info.autographImage && info.autographImage.url?
                        <View style={[styles.fPart,{marginTop:10,marginBottom: 55}]}>
                            <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>用户签名</Text>
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this,'autographImage')}>
                                <Image source={{uri:info.autographImage.url}} resizeMode="contain" style={{height: 160}}/>
                            </TouchableOpacity>
                        </View>
                    :
                        null
                }

            </View>
        );
    }

    async _clickNursingImage() {
        var options = {
            title: "上传照片",
            cancelButtonTitle: "取消",
            takePhotoButtonTitle: "拍照",
            chooseFromLibraryButtonTitle: "选择相册",
            permissionDenied: {
                title: "提示",
                text: "没有拍照和获取相册权限",
                reTryTitle: "重试",
                okTitle: "确定"
            },
            mediaType:"photo",
            quality: 0.8,
            maxHeight: parseInt(deviceHeight*2),
            maxWidth: parseInt(deviceWidth*2),
            storageOptions: {
                skipBackup: true,
                path: "images"
            }
        };
        // 照片
        ImagePicker.showImagePicker(options, response => {
            // this.setState({
            //     disableUpload:false,
            // })
            // Same code as in above section!
            console.log('test======response',JSON.stringify(response));
            if (response.error) {
                console.log("ImagePicker Error: ", response.error);
            } else {
                if (response.didCancel) {
                    console.log("User cancelled image picker");
                    return;
                }
                this.setState({showLoading:true});
                console.log('test0000000000',response.uri);
                // let fileData = "data:image/jpeg;base64," + response.data;
                this._postPictureData(response.uri,response.fileName)
                // this._completeUpload(response.uri,fileData);
            }
        });

        return false;
    }

    async _postPictureData(fileUri,fileName){
        let file = {uri:fileUri,name:fileName,type:'image/jpeg'}
        let result = await api.upload('/file/upload',file,'ORDER')
        console.log('test------------',result);
        if (result.cd == 0) {
            this._completeUpload(result.data)
        }else{
            this.setState({
                showLoading:false,
            })
        }
    }

    async _completeUpload(pictureFile){
        let {orderDetail,nursingPictureList} = this.state;
        let result = await api.post("/order/addInServiceImage",{orderId:orderDetail.id,imageId:pictureFile.id})
        console.log('_completeUpload--------',result);
        if (result.cd == 0) {
            nursingPictureList.push(pictureFile);
            console.log('test',nursingPictureList);
            this.setState({
                showLoading:false,
                nursingPictureList,
            })
            this._onRefresh();
            console.log('_completeUpload---',nursingPictureList);
        }else{
            Toast.bottom("上传失败");
            this.setState({showLoading:false})
        }
    }

    async _deletePicture(index){
        let {nursingPictureList} = this.state;
        let picture = nursingPictureList[index];
        this.setState({
            showLoading:true,
        })
        if (picture) {
            let result = await api.post("/order/deleteInServiceImage",{imageId:picture.id})
            if (result.cd == 0) {
                nursingPictureList.splice(index,1)
                console.log('test_deletePicture',nursingPictureList);
                this.setState({
                    nursingPictureList,
                    openDeletePicture:false,
                    showLoading:false,
                })
            }else{
                Toast.bottom(result.msg);
                this.setState({
                    showLoading:false,
                    openDeletePicture:false,
                })
            }
        }
    }

    _renderDeletePictureDialog(){
        let {deleteIndex} = this.state;
        return (
            <SimpleDialog
                offset={0}
                showModal={this.state.openDeletePicture}
                closeOnTouchOutside={false}
                dialogContainerStyle={{marginLeft:60,marginRight:60,marginTop: 240}}
                parent={this}
                modalDidOpen={() => console.log('modal did open')}
                modalDidClose={() => console.log('modal did close')}>
                    <View style={styles.dialogContainer}>
                        <View style={{alignItems:'center',marginTop:40}}>
                            <Text style={styles.dialogBodyText}>
                                确定删除该照片吗？
                            </Text>
                        </View>
                        <View style={[styles.submitBtnContainer,{marginTop:40}]}>
                            <Touch onPress={() =>{this.setState({openDeletePicture: false})}} style={styles.submitCancelBtn}>
                                <Text style={styles.submitBtnText}>不删除</Text>
                            </Touch>
                            <Touch onPress={this._deletePicture.bind(this, deleteIndex)} style={styles.submitOkBtn}>
                                <Text style={[styles.submitBtnText,{color:'#EA5404'}]}>确定</Text>
                            </Touch>
                        </View>
                    </View>
              </SimpleDialog>
        )
    }

    _renderHandSignDialog(){
        return (
            <SimpleDialog
                offset={0}
                showModal={this.state.openHandSignDialog}
                closeOnTouchOutside={false}
                dialogContainerStyle={{marginLeft:40,marginRight:40,marginTop: 240}}
                parent={this}
                modalDidOpen={() => console.log('modal did open')}
                modalDidClose={() => console.log('modal did close')}>
                    <View style={styles.dialogContainer}>
                        <View style={{alignItems:'center',marginTop:40}}>
                            <Text style={styles.dialogBodyText}>
                                请用户进行签名
                            </Text>
                        </View>
                        <View style={[styles.submitBtnContainer,{marginTop:40}]}>
                            <Touch onPress={() =>{this.setState({openHandSignDialog: false})}} style={styles.submitCancelBtn}>
                                <Text style={styles.submitBtnText}>暂不签名</Text>
                            </Touch>
                            <Touch onPress={this._openHandSignActivity.bind(this)} style={styles.submitOkBtn}>
                                <Text style={[styles.submitBtnText,{color:'#EA5404'}]}>立即签名</Text>
                            </Touch>
                        </View>
                    </View>
              </SimpleDialog>
        )
    }

    _openHandSignActivity(){
        let {orderDetail} = this.state;
        Navigation.startHandSignActivity({order_id:orderDetail.id});
        this.setState({openHandSignDialog:false})
    }

    _showDeleteDialog(index){
        this.setState({
            deleteIndex:index,
            openDeletePicture:true,
        })
    }

    _renderPicture(info){
        let {nursingPictureList} = this.state;
        if (info.status == 1 || info.status == 2 || info.status == -1) {
            return null;
        }
        if ((!nursingPictureList || nursingPictureList.length == 0) && info.status != 3) {
            return null
        }
        return(
            <View style={[styles.fPart,{marginTop:10}]}>
                    <Text style={{textAlign:'left',color:'#B5B5B5',marginBottom: 11.5}}>服务中</Text>
                    <View style={{flex:1,flexWrap: 'wrap',flexDirection:'row'}}>
                        {nursingPictureList.map((item,index) => {
                            
                            return (
                                <View style={[{marginRight:10,marginTop: 10}]} key={index} >
                                    <View style={{position:'relative'}}>
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._previewNursingPicture.bind(this,index)}
                                        >
                                            <View style={[styles.uploadMultiPictureContainer,{marginTop: 6,marginRight:6}]}>
                                                <Image source={{uri:item.url}}  style={{width:50,height:50}}/>
                                            </View>
                                        </TouchableOpacity>
                                        
                                        {
                                            info.status == 3 ?
                                                <TouchableOpacity
                                                    accessible={true}
                                                    activeOpacity={0.7}
                                                    onPress={ this._showDeleteDialog.bind(this,index)}
                                                    style={{width:24,height:24,position:'absolute',right:-12,top:0}}
                                                >
                                                    <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                                </TouchableOpacity>
                                            :
                                            null
                                        }
                                        
                                    </View>
                                    
                                </View>
                            )
                        })}

                        {
                            info.status == 3 ?
                                <View style={[{marginRight:10,marginTop: 10}]} >

                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickNursingImage.bind(this)}
                                    >
                                        <View style={[styles.uploadMultiPictureContainer,{marginTop: 6,marginRight:6}]}>
                                            <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                        </View>
                                    </TouchableOpacity>  
                                </View>
                            :
                            null
                        }
                        
                        
                        

                    </View>
                </View>
        )
    }

   async _sendPayLink(info) {
        if (info.isSendPayLink == 1) {
            return
        }

        let result = await api.post("/order/sendPayLink",{orderId:info.id});
        if (result.cd != 0) {
           Toast.bottom(result.msg);
           return;
        }

        // this.props.navigator.pop();
        this._onRefresh();
        // Toast.bottom('发送成功！');
        this.Emitter.emit('gotoPage', 1);
        this.Emitter.emit('order.onload');

    }

    _renderNursingF(info){
        let status = info.status;
        let {order} = this.props;
        let user = this.props.session.user;
        let user_role = this.props.session.user && this.props.session.user.role;
        console.log('test======_renderNursingF1',info.createUser);
        console.log('test======_renderNursingF2',user.id);
        console.log('test======_renderNursingF3',info.createUser == user.id);

        if(status == 0){

           return( 
                <View style={styles.actionBottomContainer}>
                    <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                        <Text style={[styles.actionBtn,info.isThirdParty?{color:'#565656',fontSize:15, borderLeftWidth: StyleSheet.hairlineWidth,borderColor: '#DDDDDD'}:{color:'#565656',fontSize:15}]}>取消</Text>
                    </Touch>
                    <Touch style={info.isSendPayLink == 0 ? styles.actionBtnContainer:styles.actionDisabledBtnContainer} activeOpacity={0.7} onPress={this._sendPayLink.bind(this, info)}>
                        <Text style={styles.actionBtn}>发送支付链接</Text>
                    </Touch>

                </View>)

           

        }else if(status == 1){
            return (
                user_role == 1?
                    
                    <View style={styles.actionBottomContainer}>

                        <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.actionBtn,info.isThirdParty?{color:'#565656',fontSize:15, borderLeftWidth: StyleSheet.hairlineWidth,borderColor: '#DDDDDD'}:{color:'#565656',fontSize:15}]}>取消</Text>
                        </Touch>
                        {
                            user && user.village?
                                <Touch style={styles.actionBtnContainer} activeOpacity={0.7} onPress={this._robOrder.bind(this, info)}>
                                    <Text style={styles.actionBtn}>抢单</Text>
                                </Touch>
                            :
                                <Touch style={styles.actionBtnContainer} activeOpacity={0.7} onPress={this._dispatchOrder.bind(this, info, 1)}>
                                    <Text style={styles.actionBtn}>派单</Text>
                                </Touch>
                        }
                    </View>
                :
                    (
                        user_role==2&&info.service_type=='lockkey'?
                            null
                        :
                            <View style={styles.actionBottomContainer}>
                                <Touch style={[styles.actionBtnContainer,{alignItems: 'center'}]} accessible={true} activeOpacity={0.7} onPress={this._robOrder.bind(this, info)}>
                                    <Text style={[styles.actionBtn, {width: '100%'}]}>抢单</Text>
                                </Touch>
                            </View>
                    )
            )
        }else if(status == 2){//待服务
            return (
                user_role == 1?
                    <View style={[styles.actionBottomContainer,{backgroundColor:'#fff'}]}>
                        <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.95} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.actionBtn,{color:'#565656',fontSize:15}]}>取消</Text>
                        </Touch>
                        {
                            info.isThirdParty?
                                <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._getObj.bind(this, info)}>
                                    <Text style={styles.actionBtn}>{info.service_type=='other' || info.service_type == 'nursing' ?'立即服务':'我已取货'}</Text>
                                </Touch>
                            :
                                user && user.village?
                                    <View style={info.createUser != user.id ?{flexDirection:'row',flex:2}:{flexDirection:'row',flex:1}}>
                                        {info.createUser != user.id ? <View style={{height:20,width:0.5,backgroundColor:'#DDDDDD',marginTop: 11}}></View> :null}
                                        {
                                            info.createUser != user.id ? 
                                                <Touch style={styles.actionMiddleBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._turnOrder.bind(this, info)}>
                                                    <Text style={[styles.actionBtn,{color:'#565656'}]}>转单</Text>
                                                </Touch>
                                            : 
                                                null
                                        }
                                        
                                        <Touch style={[styles.actionBtnContainer,info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? {backgroundColor:'#dedede'}:{}]} activeOpacity={0.7} accessible={true} onPress={info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? null : this._getObj.bind(this, info)}>
                                            <Text style={styles.actionBtn}>{info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? '等待用户支付中' : info.service_type=='other' || info.service_type == 'nursing' ? '立即服务':'我已取货'}</Text>
                                        </Touch>
                                    </View>
                                :
                                    <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._dispatchOrder.bind(this, info, 0)}>
                                        <Text style={styles.actionBtn}>转单</Text>
                                    </Touch>
                        }
                    </View>
                :
                    <View style={styles.actionBottomContainer}>
                        <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.9} onPress={this._turnOrder.bind(this, info)}>
                            <Text style={[styles.actionBtn,{color:'#565656',fontSize:15}]}>转单</Text>
                        </Touch>
                        <Touch style={[styles.actionBtnContainer,info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? {backgroundColor:'#dedede'}:{}]} activeOpacity={0.7} accessible={true} onPress={info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? null : this._getObj.bind(this, info)}>
                            <Text style={styles.actionBtn}>{info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? '等待用户支付中':info.service_type=='other' || info.service_type == 'nursing' ? '立即服务':'我已取货'}</Text>
                        </Touch>
                    </View>
            )
        }else if (status == 3) {//服务中
            return (
                <View style={styles.actionBtnTowContainer}>
                    <Touch style={styles.actionOneContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Text style={styles.actionOne}>联系用户</Text>
                    </Touch>

                    <Touch  
                        style={[styles.actionTowContainer,
                            (info.servicePayStatus == 1)
                                ? {backgroundColor:'#dedede',color:'#b5b5b5'}
                                : {}]} 
                        activeOpacity={0.7} 
                        onPress={
                            (info.autographed == 0 && info.servicePayStatus == 0)
                            ?
                                this._getComplete.bind(this, info)
                            :
                                (info.servicePayStatus == 1) 
                                ?
                                    null
                                :
                                    (info.autographed == 0 && info.servicePayStatus == 2)
                                    ?
                                        ()=>{this.setState({openHandSignDialog:true})}
                                    :
                                        (info.autographed == 1 && info.servicePayStatus == 0 || info.autographed == 1 && info.servicePayStatus == 2)
                                        ?
                                            this._updateStatus.bind(this,info.id)
                                        :
                                            null}
                                    
                        >
                        <Text 
                            style={[styles.actionBtn,
                                (info.servicePayStatus == 1)
                                ?{color:'#b5b5b5'}
                                :{}]}>
                            {this._renderNursingFButton(info)}
                        </Text>
                    </Touch>
                </View>
            )
        }else{
            return null;
        }
    }

    _renderNursingFButton(info){
        if (info.status == 3) {
            if (info.autographed == 0 && info.servicePayStatus == 0) {//完成设置金额
                return "我已完成"
            }else if (info.autographed == 0 && info.servicePayStatus == 1) {//等待支付
                return "用户支付服务费用中"
            }else if (info.autographed == 0 && info.servicePayStatus == 2) {//签名
                return "用户签名"
            }else if (info.autographed == 1 && info.servicePayStatus == 0 || info.autographed == 1 && info.servicePayStatus == 2) {//回家确认
                return "我已到家"
            }else if (info.autographed == 1 && info.servicePayStatus == 1) {
                return "用户支付服务费用中"
            }
        }else if (info.status == 4) {
            
        }
    }

    //护理站服务人员到达安全点后完成订单更新订单状态为已完成
    async _updateStatus(id){
        this.setState({showLoading:true});
        let {session} = this.props;
        let {user_phone} = this.state.orderDetail;
        let res = await api.post("/order/updatestatus", {
            id: id,
            status: 4,
            cancelReason:''
        });
        if(res.cd == 1){

            this.setState({
                showLoading:false,
            })
            Toast.bottom(res.msg);
            return;
        }
        if (res.data) {
            let ownerInfo = await api.post("/housekeeper/ownerinfobyphone", {
                phone: user_phone
            });
            if (ownerInfo.data) {
                // let send_text = "";
                // let orderTrack = await api.post("/order/tracksdetail", {
                //     id: id
                // });
                // if (orderTrack.data) {
                //     let delayTime = (
                //         (moment(orderTrack.data.order_endsend_time) -
                //             moment(orderTrack.data.order_hkget_time)) /
                //         60000
                //     ).toFixed(0);

                //     // let { session } = this.props;
                //     let web_base_url = "";
                //     if (session && session.user && session.user.product && session.user.product.baseUrl) {
                //         web_base_url = session.user.product.baseUrl;
                //     }else{
                //         web_base_url = config.WEB_BASE_URL;
                //     }
                //     send_text =
                //         "您的订单已完成。<a href='" +
                //         web_base_url +
                //         "/weichart/order?order_id=" +
                //         id +
                //         "&type=ORDER_REWARD&othertype=nursing'>评价服务</a>";
                //     let json = JSON.stringify({
                //         touser: ownerInfo.data.wxOpenId,
                //         msgtype: "text",
                //         text: {
                //             content: send_text
                //         }
                //     });

                //     let send_res = await api.post("/wx/customsend", { json });
                // }

            } else {
                // this.refs.toast.show('绑定的用户不存在');
            }

            this.setState({
                showLoading:false,
            })
            this._onRefresh();
            // this.props.navigator.pop();
            // let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
            //     Emitter.emit("pop");

        }else{
            this.setState({
                showLoading:false,
            })
            Toast.bottom("该笔订单已完成，请刷新后重试");
        }
    }

    _renderF(info){
        let status = info.status;
        let {order} = this.props;
        let user = this.props.session.user;
        let user_role = this.props.session.user && this.props.session.user.role;
        console.log('test======_renderF',info.createUser);
        console.log('test_renderF_renderF_renderF_renderF_renderF',user.id);
        console.log('test_00000000',info.createUser == user.id);

        if(status == 0){

           return( 
                <View style={styles.actionBottomContainer}>
                    <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                        <Text style={[styles.actionBtn,info.isThirdParty?{color:'#565656',fontSize:15, borderLeftWidth: StyleSheet.hairlineWidth,borderColor: '#DDDDDD'}:{color:'#565656',fontSize:15}]}>取消</Text>
                    </Touch>
                    <Touch style={info.isSendPayLink == 0 ? styles.actionBtnContainer:styles.actionDisabledBtnContainer} activeOpacity={0.7} onPress={this._sendPayLink.bind(this, info)}>
                        <Text style={styles.actionBtn}>发送支付链接</Text>
                    </Touch>

                </View>)

           

        }else if(status == 1){
            return (
                user_role == 1?
                    
                    <View style={styles.actionBottomContainer}>

                        <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.actionBtn,info.isThirdParty?{color:'#565656',fontSize:15, borderLeftWidth: StyleSheet.hairlineWidth,borderColor: '#DDDDDD'}:{color:'#565656',fontSize:15}]}>取消</Text>
                        </Touch>
                        {
                            user && user.village?
                                <Touch style={styles.actionBtnContainer} activeOpacity={0.7} onPress={this._robOrder.bind(this, info)}>
                                    <Text style={styles.actionBtn}>抢单</Text>
                                </Touch>
                            :
                                <Touch style={styles.actionBtnContainer} activeOpacity={0.7} onPress={this._dispatchOrder.bind(this, info, 1)}>
                                    <Text style={styles.actionBtn}>派单</Text>
                                </Touch>
                        }
                    </View>
                :
                    (
                        user_role==2&&info.service_type=='lockkey'?
                            null
                        :
                            <View style={styles.actionBottomContainer}>
                                <Touch style={[styles.actionBtnContainer,{alignItems: 'center'}]} accessible={true} activeOpacity={0.7} onPress={this._robOrder.bind(this, info)}>
                                    <Text style={[styles.actionBtn, {width: '100%'}]}>抢单</Text>
                                </Touch>
                            </View>
                    )
            )
        }else if(status == 2){//待服务
            return (
                user_role == 1?
                    <View style={[styles.actionBottomContainer,{backgroundColor:'#fff'}]}>
                        <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.95} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.actionBtn,{color:'#565656',fontSize:15}]}>取消</Text>
                        </Touch>
                        {
                            info.isThirdParty?
                                <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._getObj.bind(this, info)}>
                                    <Text style={styles.actionBtn}>{info.service_type=='other' || info.service_type == 'nursing' ?'立即服务':'我已取货'}</Text>
                                </Touch>
                            :
                                user && user.village?
                                    <View style={info.createUser != user.id ?{flexDirection:'row',flex:2}:{flexDirection:'row',flex:1}}>
                                        {info.createUser != user.id ? <View style={{height:20,width:0.5,backgroundColor:'#DDDDDD',marginTop: 11}}></View> :null}
                                        {
                                            info.createUser != user.id ? 
                                                <Touch style={styles.actionMiddleBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._turnOrder.bind(this, info)}>
                                                    <Text style={[styles.actionBtn,{color:'#565656'}]}>转单</Text>
                                                </Touch>
                                            : 
                                                null
                                        }
                                        
                                        <Touch style={[styles.actionBtnContainer,info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? {backgroundColor:'#dedede'}:{}]} activeOpacity={0.7} accessible={true} onPress={info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? null : this._getObj.bind(this, info)}>
                                            <Text style={styles.actionBtn}>{info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? '等待用户支付中' : info.service_type=='other' || info.service_type == 'nursing' ? '立即服务':'我已取货'}</Text>
                                        </Touch>
                                    </View>
                                :
                                    <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._dispatchOrder.bind(this, info, 0)}>
                                        <Text style={styles.actionBtn}>转单</Text>
                                    </Touch>
                        }
                    </View>
                :
                    <View style={styles.actionBottomContainer}>
                        <Touch style={[styles.actionBtnContainer,{backgroundColor:'#fff',borderWidth:0.5, borderColor:'#fff'}]} accessible={true} activeOpacity={0.9} onPress={this._turnOrder.bind(this, info)}>
                            <Text style={[styles.actionBtn,{color:'#565656',fontSize:15}]}>转单</Text>
                        </Touch>
                        <Touch style={[styles.actionBtnContainer,info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? {backgroundColor:'#dedede'}:{}]} activeOpacity={0.7} accessible={true} onPress={info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? null : this._getObj.bind(this, info)}>
                            <Text style={styles.actionBtn}>{info.service_type == "nursing" && info.unservedCostPayStatus == 1 ? '等待用户支付中':info.service_type=='other' || info.service_type == 'nursing' ? '立即服务':'我已取货'}</Text>
                        </Touch>
                    </View>
            )
        }else if (status == 3) {//服务中
            let s = "";
            if (info.service_type == "nursing") {
                s = "用户"
            }else{
                s = "业主"
            }
            return (
                <View style={styles.actionBtnTowContainer}>
                    <Touch style={styles.actionOneContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Text style={styles.actionOne}>{info.service_type == "nursing"?`联系用户`:`联系收件人`}</Text>
                    </Touch>

                    <Touch  
                        style={[styles.actionTowContainer,
                            (info.service_type=='buy'||info.service_type=='other'|| info.service_type == 'nursing')&&(info.obj_pay_status == 1||info.servicePayStatus == 1)
                                ? {backgroundColor:'#dedede',color:'#b5b5b5'}
                                : (info.service_type == "express" && info.expressCostStatus == 1)
                                    ?{backgroundColor:'#dedede',color:'#b5b5b5'}
                                    :{}]} 
                        activeOpacity={0.7} 
                        onPress={
                            (info.obj_pay_status == 1||info.servicePayStatus == 1)&&(info.service_type=='buy'||info.service_type=='other' || info.service_type=='nursing')?
                                null
                            :
                                (info.service_type == "express" && info.expressCostStatus == 1) ?
                                    null
                                :
                                    this._getComplete.bind(this, info)}
                        >
                        <Text 
                            style={[styles.actionBtn,
                                (info.service_type=='buy'||info.service_type=='other' || info.service_type == 'nursing')&&(info.obj_pay_status == 1||info.servicePayStatus == 1)
                                ?{color:'#b5b5b5'}
                                :(info.service_type == "express" && info.expressCostStatus == 1)
                                    ?{color:'#b5b5b5'}
                                    :{}]}>

                            {info.service_type == "buy"
                                ? info.obj_pay_status == 1
                                    ? "等待用户支付中"
                                    : "完成并设置金额"
                                : info.service_type == "express" && info.expressCostStatus == 1
                                    ? "业主支付快递费用中"
                                    : (info.service_type == "other" || info.service_type == "nursing")
                                        ? info.servicePayStatus == 1
                                            ? s+"支付服务费用中"
                                            : "我已完成"
                                        : "我已完成"}</Text>
                    </Touch>
                </View>
            )
        }else{
            return null;
        }
    }



    _renderDialog(id){
        let {turn} = this.state;
        let line1 = "", line2 = "";
        let cancel = "暂不";
        if(turn == 1){
            line1 = "确定发起转单吗？";
            line2 = "发起后，订单将不会显示在列表中";
            cancel = "取消";
        }else{
            line1 = "取消前请先和用户确认，";
            line2 = "确定取消吗？";
        }

        return (
            <SimpleDialog
                offset={0}
                showModal={this.state.open}
                closeOnTouchOutside={false}
                dialogContainerStyle={{marginLeft:60,marginRight:60,marginTop: 180}}
                parent={this}
                modalDidOpen={() => console.log('modal did open')}
                modalDidClose={() => console.log('modal did close')}>
                    <View style={styles.dialogContainer}>
                        <View style={{alignItems:'center',marginTop:40}}>
                            <Text style={styles.dialogBodyText}>
                                {line1}
                            </Text>
                            <Text style={styles.dialogBodyText}>
                                {line2}
                            </Text>
                        </View>
                        <View style={[styles.submitBtnContainer,{marginTop:40}]}>
                            <Touch onPress={() =>{this.setState({open: false})}} style={styles.submitCancelBtn}>
                                <Text style={styles.submitBtnText}>{cancel}</Text>
                            </Touch>
                            <Touch onPress={this._cancelOrder.bind(this, id)} style={styles.submitOkBtn}>
                                <Text style={[styles.submitBtnText,{color:'#EA5404'}]}>确定</Text>
                            </Touch>
                        </View>
                    </View>
              </SimpleDialog>
        )
    }

    async _cancelOrder(id,reason){
        let {turn,service_type} = this.state;

        this.setState({open: false});
        let res;
        

        if(turn == 1){// 管家和业主转单
            InteractionManager.runAfterInteractions(() => {
                this.props.navigator.pop();
            });
            res = await api.post("/order/turn",{id:id});
        }else{
            if (service_type && service_type == "shops") {
                this._refundShopMoney(id);
            }
            if (service_type && service_type == "activity") {
                this._cancelActivityOrder(id)
            }
            res = await api.post("/order/updatestatus",{id:id,status:-1,cancelReason:reason});
        }
        if(res.data){
            if(turn == 1) {
                Toast.bottom("转单成功");
            }else{
                this.refs.cancelOrderDialog._hide();
                Toast.bottom("取消成功");
                this.setState({
                    showCancelDialog:false,
                },()=>{
                    this.props.navigator.pop();
                })
                
            }
            this.Emitter.emit('order.onload');
        }else{
            if (turn == 1) {
                Toast.bottom("转单失败")
            }else{
                Toast.bottom("取消订单失败");
                this.refs.cancelOrderDialog._hide();
                this.setState({
                    showCancelDialog:false,
                })
            }
            
        }
    }

    async _refundShopMoney(id){
        let result = await api.post("/privilege/shops/orderRefund",{oid:id})
        // if (result.cd != 0) {
        //     Toast.bottom(result.msg);
        // }else{
        //     Toast.bottom("取消订单成功");
        //     this.Emitter.emit('order.onload');
        // }
    }

    // 取消活动报名订单
    async _cancelActivityOrder(id){
        let result = await api.post("/configurable/cancelOrder",{id})
    }

    _onConfirmCancelOrder(reason){
      let orderId = this.state.orderDetail.id;
      if (reason) {
          this._cancelOrder(orderId,reason);
      }else{
        Toast.bottom('请输入取消原因');
      }
      
    }

    _onCancelCancelOrder(){
        console.log('test','-----------');
      this.setState({
        showCancelDialog:false,
      })
    }

    _renderCancelReasonDialog(){
        return (<CancelOrderReasonDialog ref="cancelOrderDialog" showModal={this.state.showCancelDialog} onCancel={this._onCancelCancelOrder.bind(this)} onConfirm={this._onConfirmCancelOrder.bind(this)}/>)
    }

    render() {
        let order = this.state.orderDetail;
        let {ownerInfo,totalServiceFee = 0.00,showVipTips = false} = this.state;
        return (
            !order?
            <View style={{flex:1}}>
                {!this.state.isShowLoadBar?<View style={styles.progressBar}><ProgressBar /></View>:null}
                <ToastTip ref="toast" offsetY={160}/>
            </View> :
            <View style={styles.wrapper}>
                <ScrollView style={styles.container}>
                    {showVipTips?
                        <View style={{height: 40,backgroundColor:'#FFFCED',borderBottomWidth:0.5,borderColor:'#E8E8E8',flexDirection:'row',paddingLeft:15,alignItems:'center'}}>
                            <Text style={{color:'#333333',fontSize:13}}>
                                服务费用
                                <Text style={{color:'#FF8200'}}>¥{totalServiceFee}</Text>
                                ，VIP会员每月免费
                                <Text style={{color:'#FF8200'}}>15</Text>
                                次，本月剩余
                                <Text style={{color:'#FF8200'}}>{ownerInfo.keeperServiceLeftCount}</Text>
                                次
                            </Text>
                        </View>
                        :
                        null
                    }
                    
                    <View style={styles.content}>
                        
                        {this.serviceTypeMap[order.service_type]['m'](order)}
                    </View>
                </ScrollView>
                {order.service_type == "nursing"?this._renderNursingF(order):this._renderF(order)}
                {this._renderDialog(order.id)}
                {this._renderCancelReasonDialog()}
                {this._renderDeletePictureDialog()}
                {this._renderHandSignDialog()}
                <LoadingTip show={this.state.showLoading}/>
                <ToastTip ref="toast" offsetY={160}/>
            </View>
        );
    }
}

var connectHelper = require('../../services/connectHelper');
OrderDetail = connectHelper(state => state)(OrderDetail);

module.exports = OrderDetail;
